Fecha actualización: 2020-04-02 00:00:00

#collapse-hide
df.head(10)
pais dateRep day month year cases deaths geoId countryterritoryCode popData2018 min_date days cum_cases cum_deaths date_int max_cases
13 China 2019-12-31 31.0 12.0 2019.0 27.0 0.0 CN CHN 1.392730e+09 2019-12-31 0.0 27.0 0.0 20191231.0 82395.0
80 China 2020-01-01 1.0 1.0 2020.0 0.0 0.0 CN CHN 1.392730e+09 2019-12-31 1.0 27.0 0.0 20200101.0 82395.0
147 China 2020-01-02 2.0 1.0 2020.0 0.0 0.0 CN CHN 1.392730e+09 2019-12-31 2.0 27.0 0.0 20200102.0 82395.0
214 China 2020-01-03 3.0 1.0 2020.0 17.0 0.0 CN CHN 1.392730e+09 2019-12-31 3.0 44.0 0.0 20200103.0 82395.0
281 China 2020-01-04 4.0 1.0 2020.0 0.0 0.0 CN CHN 1.392730e+09 2019-12-31 4.0 44.0 0.0 20200104.0 82395.0
348 China 2020-01-05 5.0 1.0 2020.0 15.0 0.0 CN CHN 1.392730e+09 2019-12-31 5.0 59.0 0.0 20200105.0 82395.0
415 China 2020-01-06 6.0 1.0 2020.0 0.0 0.0 CN CHN 1.392730e+09 2019-12-31 6.0 59.0 0.0 20200106.0 82395.0
482 China 2020-01-07 7.0 1.0 2020.0 0.0 0.0 CN CHN 1.392730e+09 2019-12-31 7.0 59.0 0.0 20200107.0 82395.0
549 China 2020-01-08 8.0 1.0 2020.0 0.0 0.0 CN CHN 1.392730e+09 2019-12-31 8.0 59.0 0.0 20200108.0 82395.0
616 China 2020-01-09 9.0 1.0 2020.0 0.0 0.0 CN CHN 1.392730e+09 2019-12-31 9.0 59.0 0.0 20200109.0 82395.0

Casos acumulados por país

Evolución Diaria

#collapse-hide
source = df.where(df['max_cases'] >= 10000)
label = alt.selection_single(
    encodings=['x'], # limit selection to x-axis value
    on='mouseover',  # select on mouseover events
    nearest=True,    # select data point nearest the cursor
    empty='none'     # empty selection includes no data points
)

alt.data_transformers.enable('default', max_rows=None)

# define our base line chart of stock prices
base = alt.Chart().mark_line().encode(
    alt.X('dateRep:T'),
    alt.Y('cum_cases:Q', scale=alt.Scale(type='log')),
    alt.Color('pais:N')
)

alt.layer(
    base, # base line chart
    
    # add a rule mark to serve as a guide line
    alt.Chart().mark_rule(color='#aaa').encode(
        x='dateRep:T'
    ).transform_filter(label),
    
    # add circle marks for selected time points, hide unselected points
    base.mark_circle().encode(
        opacity=alt.condition(label, alt.value(1), alt.value(0))
    ).add_selection(label),

    # add white stroked text to provide a legible background for labels
    base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=5).encode(
        text='cum_cases:Q'
    ).transform_filter(label),
    
    base.mark_text(align='left', dx=35, dy=-5, stroke='white', strokeWidth=5).encode(
        text='pais:N'
    ).transform_filter(label),

    # add text labels for stock prices
    base.mark_text(align='left', dx=5, dy=-5).encode(
        text='cum_cases:Q'
    ).transform_filter(label),
    
    base.mark_text(align='left', dx=35, dy=-5).encode(
        text='pais:N'
    ).transform_filter(label),
    
    data=source
).properties(
    width=700,
    height=400
)

Evolución de casos detectados por día del primer caso detectado en cada país

#collapse-hide
source = df.where(df['max_cases'] >= 1000)
label = alt.selection_single(
    encodings=['x'], # limit selection to x-axis value
    on='mouseover',  # select on mouseover events
    nearest=True,    # select data point nearest the cursor
    empty='none'     # empty selection includes no data points
)

alt.data_transformers.enable('default', max_rows=None)

# define our base line chart of stock prices
base = alt.Chart().mark_line().encode(
    alt.X('days:Q'),
    alt.Y('cum_cases:Q', scale=alt.Scale(type='log')),
    alt.Color('pais:N')
)

alt.layer(
    base, # base line chart
    
    # add a rule mark to serve as a guide line
    alt.Chart().mark_rule(color='#aaa').encode(
        x='days:Q'
    ).transform_filter(label),
    
    # add circle marks for selected time points, hide unselected points
    base.mark_circle().encode(
        opacity=alt.condition(label, alt.value(1), alt.value(0))
    ).add_selection(label),

    # add white stroked text to provide a legible background for labels
    base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=2).encode(
        text='cum_cases:Q'
    ).transform_filter(label),

    # add text labels for stock prices
    base.mark_text(align='left', dx=5, dy=-5).encode(
        text='cum_cases:Q'
    ).transform_filter(label),
    
    base.mark_text(align='left', dx=40, dy=-5).encode(
        text='pais:N'
    ).transform_filter(label),
    
    data=source
).properties(
    width=700,
    height=400
)

Escala logaritmica de casos y casos acumulados por pais

#collapse-hide
source = df.where(df['cases'] > 0)
source = source.where(df['max_cases'] >= 30000)
label = alt.selection_single(
    encodings=['x'], # limit selection to x-axis value
    on='mouseover',  # select on mouseover events
    nearest=True,    # select data point nearest the cursor
    empty='none'     # empty selection includes no data points
)

alt.data_transformers.enable('default', max_rows=None)

# define our base line chart of stock prices
base = alt.Chart().mark_line(point=True).encode(
    alt.X('cum_cases:Q', axis=alt.Axis(grid=False), scale=alt.Scale(type='log')),
    alt.Y('cases:Q', axis=alt.Axis(grid=False), scale=alt.Scale(type='log')),
    alt.Color('pais:N')
)

alt.layer(
    base, # base line chart
    
    # add a rule mark to serve as a guide line
    alt.Chart().mark_rule(color='#aaa').encode(
        x='cum_cases:Q'
    ).transform_filter(label),
    
    # add circle marks for selected time points, hide unselected points
    base.mark_circle().encode(
        opacity=alt.condition(label, alt.value(1), alt.value(0))
    ).add_selection(label),

    # add white stroked text to provide a legible background for labels
    base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=2).encode(
        text='cum_cases:Q'
    ).transform_filter(label),

    # add text labels for stock prices
    base.mark_text(align='left', dx=5, dy=-5).encode(
        text='cum_cases:Q'
    ).transform_filter(label),
    
    base.mark_text(align='left', dx=40, dy=-5).encode(
        text='pais:N'
    ).transform_filter(label),
    
    data=source
).properties(
    width=700,
    height=400
)

Evolución de desesos detectados por día del primer caso detectado en cada país

#collapse-hide
source = df#.where(df['max_cases'] >= 1000)
label = alt.selection_single(
    encodings=['x'], # limit selection to x-axis value
    on='mouseover',  # select on mouseover events
    nearest=True,    # select data point nearest the cursor
    empty='none'     # empty selection includes no data points
)

alt.data_transformers.enable('default', max_rows=None)

# define our base line chart of stock prices
base = alt.Chart().mark_line().encode(
    alt.X('days:Q'),
    alt.Y('cum_deaths:Q'),
    alt.Color('pais:N')
)

alt.layer(
    base, # base line chart
    
    # add a rule mark to serve as a guide line
    alt.Chart().mark_rule(color='#aaa').encode(
        x='days:Q'
    ).transform_filter(label),
    
    # add circle marks for selected time points, hide unselected points
    base.mark_circle().encode(
        opacity=alt.condition(label, alt.value(1), alt.value(0))
    ).add_selection(label),

    # add white stroked text to provide a legible background for labels
    base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=2).encode(
        text='cum_deaths:Q'
    ).transform_filter(label),
    
    base.mark_text(align='left', dx=37, dy=-5, stroke='white', strokeWidth=2).encode(
        text='pais:N'
    ).transform_filter(label),

    # add text labels for stock prices
    base.mark_text(align='left', dx=5, dy=-5).encode(
        text='cum_deaths:Q'
    ).transform_filter(label),
    
    base.mark_text(align='left', dx=37, dy=-5).encode(
        text='pais:N'
    ).transform_filter(label),
    
    data=source
).properties(
    width=700,
    height=400
)

Evolución de desesos detectados por fecha en cada país

#collapse-hide
source = df#.where(df['max_cases'] >= 1000)
label = alt.selection_single(
    encodings=['x'], # limit selection to x-axis value
    on='mouseover',  # select on mouseover events
    nearest=True,    # select data point nearest the cursor
    empty='none'     # empty selection includes no data points
)

alt.data_transformers.enable('default', max_rows=None)

# define our base line chart of stock prices
base = alt.Chart().mark_line().encode(
    alt.X('dateRep:T'),
    alt.Y('cum_deaths:Q'),
    alt.Color('pais:N')
)

alt.layer(
    base, # base line chart
    
    # add a rule mark to serve as a guide line
    alt.Chart().mark_rule(color='#aaa').encode(
        x='dateRep:T'
    ).transform_filter(label),
    
    
    
    # add circle marks for selected time points, hide unselected points
    base.mark_circle().encode(
        opacity=alt.condition(label, alt.value(1), alt.value(0))
    ).add_selection(label),

    # add white stroked text to provide a legible background for labels
    base.mark_text(align='right', dx=5, dy=-5, stroke='white', strokeWidth=5).encode(
        text='cum_deaths:Q'
    ).transform_filter(label),
    
    base.mark_text(align='right', dx=5, dy=-15, stroke='white', strokeWidth=5).encode(
        text='pais:N'
    ).transform_filter(label),

    # add text labels for stock prices
    base.mark_text(align='right', dx=5, dy=-5).encode(
        text='cum_deaths:Q'
    ).transform_filter(label),
    
    base.mark_text(align='right', dx=5, dy=-15).encode(
        text='pais:N'
    ).transform_filter(label),
    
    data=source
).properties(
    width=700,
    height=400
).interactive()

Casos acumulados y desesos acumulados del último día

#collapse-hide
date = data['dateRep'].max()
source = df.where(df['dateRep'] >= date)
source = source.where(source['max_cases'] >= 1000)


alt.Chart(source).mark_circle(size=100).encode(
    alt.X('cum_cases:Q'),
    alt.Y('cum_deaths:Q'),
    color='pais',
    tooltip=['pais:N', 'cum_deaths:Q', 'cum_cases:Q']
).properties(
    width=700,
    height=400
).interactive()

Relacion de casos detectados y desesos por pais

#collapse-hide
source = source.where(source['max_cases'] >= 1000)

alt.Chart(source).mark_circle(size=100).encode(
    alt.X('cum_cases:Q'),
    alt.Y('cum_deaths:Q'),
    color='pais',
    tooltip=['pais:N', 'cum_deaths:Q', 'cum_cases:Q']
).properties(
    width=700,
    height=400
).interactive()

Argentina

Curva de casos acumulados por día

#collapse-hide
source = df.where(df['pais'] == 'Argentina')
label = alt.selection_single(
    encodings=['x'], # limit selection to x-axis value
    on='mouseover',  # select on mouseover events
    nearest=True,    # select data point nearest the cursor
    empty='none'     # empty selection includes no data points
)

# define our base line chart of stock prices
base = alt.Chart().mark_line().encode(
    alt.X('days:Q'),
    alt.Y('cum_cases:Q', scale=alt.Scale(type='log')),
    alt.Color('pais:N')
)

overlay = pd.DataFrame({'cuarentena': [13]})
vline = alt.Chart(overlay).mark_rule(color='red', strokeWidth=1).encode(x='cuarentena:Q')

alt.layer(
    base, vline,# base line chart
    
    # add a rule mark to serve as a guide line
    alt.Chart().mark_rule(color='#aaa').encode(
        x='days:Q'
    ).transform_filter(label),
    
    # add circle marks for selected time points, hide unselected points
    base.mark_circle().encode(
        opacity=alt.condition(label, alt.value(1), alt.value(0))
    ).add_selection(label),

    # add white stroked text to provide a legible background for labels
    base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=5).encode(
        text='cum_cases:Q'
    ).transform_filter(label),

    # add text labels for stock prices
    base.mark_text(align='left', dx=5, dy=-5).encode(
        text='cum_cases:Q'
    ).transform_filter(label),
    
    data=source
      
).properties(
    width=700,
    height=400 )

# La línea roja marca el inicio de la cuarentena

#collapse-hide
source = df.where(df['pais'] == 'Argentina')
label = alt.selection_single(
    encodings=['x'], # limit selection to x-axis value
    on='mouseover',  # select on mouseover events
    nearest=True,    # select data point nearest the cursor
    empty='none'     # empty selection includes no data points
)

# define our base line chart of stock prices
base = alt.Chart().mark_line().encode(
    alt.X('days:Q'),
    alt.Y('cum_deaths:Q'),
    alt.Color('pais:N')
)

overlay = pd.DataFrame({'cuarentena': [13]})
vline = alt.Chart(overlay).mark_rule(color='red', strokeWidth=1).encode(x='cuarentena:Q')

alt.layer(
    base, vline, # base line chart
    
    # add a rule mark to serve as a guide line
    alt.Chart().mark_rule(color='#aaa').encode(
        x='days:Q'
    ).transform_filter(label),
    
    # add circle marks for selected time points, hide unselected points
    base.mark_circle().encode(
        opacity=alt.condition(label, alt.value(1), alt.value(0))
    ).add_selection(label),

    # add white stroked text to provide a legible background for labels
    base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=2).encode(
        text='cum_deaths:Q'
    ).transform_filter(label),

    # add text labels for stock prices
    base.mark_text(align='left', dx=5, dy=-5).encode(
        text='cum_deaths:Q'
    ).transform_filter(label),
    
    data=source
).properties(
    width=700,
    height=400
)


# La línea roja marca el inicio de la cuarentena

Casos detectados por día

#collapse-hide
source = df.where(df['pais'] == 'Argentina')
label = alt.selection_single(
    encodings=['x'], # limit selection to x-axis value
    on='mouseover',  # select on mouseover events
    nearest=True,    # select data point nearest the cursor
    empty='none'     # empty selection includes no data points
)

# define our base line chart of stock prices
base = alt.Chart().mark_line().encode(
    alt.X('dateRep:T'),
    alt.Y('cases:Q'),
    alt.Color('pais:N'),
    tooltip=['pais:N', 'dateRep:T', 'cum_cases:Q']
)

overlay = pd.DataFrame({'cuarentena': ['2020-03-17']})
vline = alt.Chart(overlay).mark_rule(color='red', strokeWidth=1).encode(x='cuarentena:T')

alt.layer(
    base, vline, # base line chart
    
    # add a rule mark to serve as a guide line
    alt.Chart().mark_rule(color='#aaa').encode(
        x='dateRep:T'
    ).transform_filter(label),
    
    # add circle marks for selected time points, hide unselected points
    base.mark_circle().encode(
        opacity=alt.condition(label, alt.value(1), alt.value(0))
    ).add_selection(label),

    # add white stroked text to provide a legible background for labels
    base.mark_text(align='left', dx=5, dy=-5, stroke='white', strokeWidth=2).encode(
        text='cases:Q'
    ).transform_filter(label),

    # add text labels for stock prices
    base.mark_text(align='left', dx=5, dy=-5).encode(
        text='cases:Q'
    ).transform_filter(label),
    
    data=source
).properties(
    width=700,
    height=400
)


# La línea roja marca el inicio de la cuarentena